/*
 * @Author: EveChee
 * @Date: 2019-12-05 19:30:41
 * @LastEditors: EveChee
 * @LastEditTime: 2021-01-13 15:05:55
 * @Description: file content
 */
const isType = (type) => (target) =>
    `[object ${type}]` === Object.prototype.toString.call(target)
const isObject = isType('Object')
const isNumber = isType('Number')
const isString = isType('String')
const isRegExp = isType('RegExp')
const isBoolean = isType('Boolean')
const isFunction = isType('Function')
const isDate = isType('Date')
function main() {
    function deepCopy(target) {
        const res = new target.constructor(target)
        for (let [key, val] of Object.entries(target))
            res[key] = Object.is(typeof val, 'object') ? deepCopy(val) : val
        return res
    }
    let obj = {
        a: 1,
        b: 2,
        c: { d: new Date('2020-12-09') },
        e: [{ oop: 123 }, { sss: 999 }]
    }
    let oo = deepCopy(obj)
    console.log(oo)
    oo.c.d
    console.log(obj)
    console.log(oo)
    /* result
	{ a: 1, b: 2, c: { d: 3 }, e: [ { oop: 123 }, { sss: 999 } ] }
	{ a: 1, b: 2, c: { d: 3 }, e: [ { oop: 123 }, { sss: 999 } ] }
	{ a: 1, b: 2, c: { d: 3 }, e: [ 1, { sss: 999 } ] }
	*/
}
main()
console.log(1234, isDate(new Date()))
// 掌握检测

// function deepCopy(target) {
// 	let res
// 	if (target && target.constructor) {
// 		res = new target.constructor()
// 		for (let [key, val] of Object.entries(res)) {
// 			res[key] = isObject(val) || Array.isArray(val) ? deepCopy(target) : val
// 		}
// 	} else {
// 		res = target
// 	}
// 	return res
// }
